<template>
  <div class="vjkaj">
    <Back />
    <div class="ban">
      <div class="swiper mySwiper">
        <div class="swiper-wrapper">
          <div
            class="swiper-slide"
            v-for="item in bannerlist"
            :key="item.imgId"
          >
            <img :src="url + item.imgUrl" alt="" />
          </div>
        </div>
      </div>
    </div>
    <ul>
      <li @click="$router.push('/follow')">
        <i class="el-icon-user"></i>关注讲师<i class="el-icon-arrow-right"></i>
      </li>
      <li @click="$router.push('/skills')">
        <i class="el-icon-star-off"></i>收藏课程<i
          class="el-icon-arrow-right"
        ></i>
      </li>
    </ul>
  </div>
</template>

<script>
import Swiper from "swiper";
import { Banner } from "@/api";
export default {
  data() {
    return {
      url: "http://192.168.10.32/yonghao/img/",
      bannerlist: [],
    };
  },
  created() {
    if (this.$store.state.userphone === "") {
      this.$router.push("/");
    } else {
      this.getBanner();
    }
    // console.log('aaa');
  },

  methods: {
    getBanner() {
      Banner().then((res) => {
        this.bannerlist = res.data.data;
      });
      setTimeout(() => {
        var swiper = new Swiper(".mySwiper", {
          loop: true,
          autoplay: {
            delay: 2500,
            disableOnInteraction: false,
          },
        });
        setInterval(() => {
          if (this.n < this.bannerlist.length) {
            this.n += 1;
          } else {
            this.n = 1;
          }
        }, 2800);
      }, 1000);
    },
  },
};
</script>

<style scoped lang="scss">
.el-icon-arrow-right {
  margin-left: 60vw;
}
.vjkaj {
  width: 100vw;
  height: 100vh;

  font-size: 4vw;
  overflow: hidden;
  > ul {
    > li {
      color: black;
      text-indent: 1rem;
      height: 8vh;
      width: 100vw;
      line-height: 8vh;
      border-bottom: 0.1vw solid #ccc;
    }
  }
}
.vjkaj .el-icon-star-off,
.vjkaj .el-icon-user {
  // margin: 0 1vw;
  font-size: 4vw;
  padding: 0 2vw;
}
.ban {
  background: yellow;
  margin-bottom: 3vh;
  margin-top: 8vh;
  width: 100%;
}
.swiper {
  width: 100%;
  overflow: hidden;
}
.swiper-slide {
  // text-align: center;
  font-size: 18px;
  background: #fff;
  justify-content: center;
  align-items: center;
}
.swiper-slide img {
  display: block;
  width: 100%;
  height: 20vh;
  object-fit: cover;
}
.mySwiper2 .swiper-slide img {
  height: 25vh;
}
</style>